package com.buddy.learn.javasource._collection;

import com.alibaba.fastjson.JSON;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Buddy
 * @date 2021/6/2
 */
public class _StringToUpperCase {


    /**
     * 给定一个List<Integer>集合list,包含100个 值，请移除被3整除的元素。
     * for(       ;       ;     ){
     * 1 2  3  4
     * }
     * modCount
     *
     * @param args
     */

    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>(100);
        for (int i = 1; i <= 100; i++) {
            list.add(i);
        }

        list = solution(list);
        System.out.println(JSON.toJSONString(list));


        //英文字母的字符串，大写字母变小写，小写字母变大写
        String s = "ABCdef";
        s = change(s);
        System.out.println(s);


    }

    private static String change(String s) {
        char[] chars = s.toCharArray();
        StringBuilder sb = new StringBuilder();
        for (char c : chars) {
            if (c >= 'a' && c <= 'z') {
                sb.append((c + "").toUpperCase());
            } else {
                sb.append((c + "").toLowerCase());
            }

        }
        return sb.toString();

    }

    private static List<Integer> solution(List<Integer> list) {

        list.removeIf(i -> i % 3 == 0);
        return list;
    }
}
